package baoxin.com.robotcoach.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import baoxin.com.robotcoach.R;

public class PicAdapter extends RecyclerView.Adapter<PicAdapter.ViewHolder> {
    private int[] pics;

    static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView step;

        public ViewHolder(View view) {
            super(view);
            step = view.findViewById(R.id.step_image);
        }
    }

    public PicAdapter(int[] pics) {
        this.pics = pics;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.gear_item,null);
        final ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.step.setImageResource(pics[position]);
    }

    @Override
    public int getItemCount() {
        return pics.length;
    }
}
